package it.sevenbits.view;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/req")
public class DBController {

	@RequestMapping(method = RequestMethod.POST)
	public ModelAndView helloWorld(HttpServletRequest request) throws ServletException, IOException {
	    
	    String type = request.getParameter("type");
	    String req = request.getParameter("request");
	    String reqArray[] = {
            type, req
        };
		ModelAndView model = new ModelAndView("index");
		try {
            WebOut web = new WebOut();
            ArrayList<String> result = web.resp(reqArray);
            model.addObject("msg", result);
        } finally {
            //out.close();

        }

		return model;
	}
}
